package com.wiscamp.ninechapters.problems.infrastructure.mappers.sets;

import com.wiscamp.ninechapters.problems.infrastructure.po.sets.ProblemSetPO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

/**
 * 习题集仓储对象
 *
 * @author yifeng
 */
@Repository
public interface ProblemSetMapper extends JpaRepository<ProblemSetPO, Long>, JpaSpecificationExecutor<ProblemSetPO> {

    /**
     * 通过习题集编号更新习题集名称
     *
     * @param setName
     * @param setId
     */
    @Modifying
    @Transactional
    @Query(value = "update ProblemSetPO e set e.setName = :setName where e.setId = :setId")
    void updateSetName(String setName, long setId);
}